﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.GermlineHistoryRecordsCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.GermlineHistoryRecordsCommandHandler
{
    /// <summary>
    /// 种母历史记录反填CommandHandler
    /// </summary>
    public class BackfillHistoryCommandHandler : IRequestHandler<BackfillHistoryCommand, Results<HistoryOutPut>>
    {


        private readonly IHistoryRecordService _service;
        public BackfillHistoryCommandHandler(IHistoryRecordService service)
        {
            _service = service;
        }


        public async Task<Results<HistoryOutPut>> Handle(BackfillHistoryCommand request, CancellationToken cancellationToken)
        {
            var list = await _service.GetHistoryByIdAsync(request.earTag);
            return Results<HistoryOutPut>.DataResult(list);
        }
    }
}
